package com.ysd.dao.impl;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

import com.ysd.entity.News;
import com.ysd.util.DBManager;

public class NewsxiangqingDaolmpl {
	public List<News> getNews(int nId){
		List<News> list = new ArrayList<News>();
		Connection conn = DBManager.getConnection();
		Statement st = null;
		ResultSet rs = null;
		try {
			st = conn.createStatement();
			rs = st.executeQuery("select * from News where newsid="+nId);
			while(rs.next()) {
				int newsid = rs.getInt("newsid");
				String newsShiJian = rs.getString("newsShiJian");
				String newsTitle = rs.getString("newsTitle");
				String newsContert = rs.getString("newsContert");
				int newsCategoryid = rs.getInt("newsCategoryid");
				News news = new News(newsid, newsShiJian, newsTitle, newsContert, newsCategoryid);
				list.add(news);
			}
			return list;
		} catch (SQLException e) {
			e.printStackTrace();
			return null;
		}finally {
			DBManager.closeAll(conn, st, rs);
		}
	}
		
	
	
}
